package com.nbjtjc.safe.mapper.know;

import com.nbjtjc.safe.model.know.SafeKnowLabel;
import com.nbjtjc.util.MyMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SafeKnowLabelMapper extends MyMapper<SafeKnowLabel> {

    @Delete("delete from safe_know_label where label =#{label}")
    int deleteByLabel(@Param("label") String label);
    @Delete("delete from safe_know_label where label=#{label} and know_id=#{knowId}")
    int deleteByLabelAndKnowId(@Param("label") String label,@Param("knowId")int knowId);

    @Delete("delete from safe_know_label where know_id=#{kId}")
    int deleteByKid(@Param("kId") int kId);

    @Update("update safe_know_label set label=#{newLabel} where label=#{label}")
    int updateByLabel(@Param("label")String label,@Param("newLabel") String newLabel);
    @Select("select distinct label from safe_know_label where know_id=#{kId}")
    List<String> selectLabelByKid(@Param("kId") int kId);
    List<SafeKnowLabel> search(@Param("kl") SafeKnowLabel safeKnowLabel);

    /**
     * 返回被打标签数量最多的标签
     * @param knowIds
     * @return
     */
    List<SafeKnowLabel> topLabel(@Param("knowIds") List<Integer> knowIds);

    @Select("select know_id from safe_know_label where label=#{label}")
    List<Integer> knowIdsByLabel(@Param("label") String label);

}